package day2.problem2;

//DP4最小花费爬楼梯

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i<n; i++) {
            arr[i] = in.nextInt();
        }
        int[] dp = new int[n+1];
        for(int i = 2; i<=n; i++) {
            dp[i] = Math.min(dp[i-1] + arr[i-1], dp[i-2] + arr[i-2]);
        }
        System.out.println(dp[n]);
    }
}

/*

dp[i]:到达第i个楼梯的最少费用

*/